< previous page page_508 next page >

Page 508
9f31265bb40b592b1929e18a47ab28e5.gif
   On Error GoTo Error_EH

   If mboolAdding Then
      moRS.AddNew
   End If

   ' Store the controls to the recordset
   Call FieldsSave

   moRS.Update

   If mboolAdding Then
      mboolAdding = False
      strName = Trim$(txtLast) & ", " & Trim$(txtFirst)
      ' Reload list box
      Call ListLoad

      lstNames.Text = strName
   Else
      ' Update List Box
      With lstNames
         .List(.ListIndex) = txtLast & ", " & _
                             txtFirst
      End With
   End If

   Call ToggleButtons

   Exit Sub

Error_EH:
   Call ErrorHandler(moRS.ActiveConnection)
   Exit Sub
End Sub
The FormSave procedure accomplishes a lot of tasks. First, it checks the module level variable mboolAdding to see whether the AddNew method needs to be called. The AddNew method informs ADO that it needs to create a new record in the table. Next, a procedure called FieldsSave() is called to move the data from the controls into the module-level recordset. After the data has been stored in the recordset, the Update method is invoked to save the data back to the database.

 
< previous page page_508 next page >

If you like this book, buy it!